﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Domain;
using Domain.Common;
using Domain.Officers;

namespace Service
{
    public class InternalService
    {
        /// <summary>
        /// 开始势力内政工作
        /// </summary>
        /// <param name="force"></param>
        /// <param name="days"></param>
        public static void StartToInternalWork(Force force, int days)
        {
            foreach (var building in force.Buildings)
            {
                building.DispatchInternalTask();
                building.DevelopExtendBuilding(days, 0);
                building.DevelopAgriculture(days, 0);
                building.DevelopCommerce(days, 0);
                building.DevelopCulture(days, 0);
                building.DevelopEndurance(days, 0);
                building.DevelopPopularFeelings(days, 0);
                building.DevelopPublicSecurity(days, 0);
                building.DevelopSoldier(days, 0);
                building.DevelopTechnology(days, 0);
                building.UpdatePopulationChange(days);
                building.GetFoodTax();
                building.GetFundTax(days);
                building.PayOffSalary();
            }
        }
        /// <summary>
        /// 获取建筑可用工作分配武将
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static List<Officer> GetOwnedOfficersByBuildingId(short id)
        {
            Domain.Building building = Domain.Building.Buildings[id];
            return building.OwnedOfficers;
        }
        /// <summary>
        /// 分配工作。内政方面
        /// </summary>
        /// <param name="bid"></param>
        /// <param name="ids"></param>
        /// <param name="workType"></param>
        /// <returns></returns>
        public static bool DispatchJob(short bid, List<int> ids, WorkType workType)
        {
            Domain.Building building = Domain.Building.Buildings[bid];
            var list = building.OwnedOfficers.Where(x => ids.Contains(x.Id)).ToList();
            list.ForEach(x =>
            {
                x.WorkType = workType;
            });
            return true;
        }
    }
}
